package com.xmu.prcs.entity;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;
/**
 * 植物身体大部位表
 * @author frequent
 *
 */
@SuppressWarnings("serial")
@Entity
@Table(name = "body", uniqueConstraints = @UniqueConstraint(columnNames = "bodyname"))
public class Body implements Serializable {

	private Integer idBody;
	private String bodyName;//部位名
	private Set<Part> parts;//小部位
	
	public Body(){
		
	}
	
	public Body(String bodyName){
		this.bodyName = bodyName;
	}

	@Id
	@GeneratedValue
	@Column(name = "idbody", unique = true, nullable = true)
	public Integer getIdBody() {
		return idBody;
	}

	public void setIdBody(Integer idBody) {
		this.idBody = idBody;
	}

	@Column(name = "bodyname", length = 10)
	public String getBodyName() {
		return bodyName;
	}

	public void setBodyName(String bodyName) {
		this.bodyName = bodyName;
	}

	@OneToMany(cascade = CascadeType.ALL)
	@JoinColumn(name = "idbody")
	public Set<Part> getParts() {
		return parts;
	}

	public void setParts(Set<Part> parts) {
		this.parts = parts;
	}
	
}
